﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="MimeType.cs" company="">
//   
// </copyright>
// <summary>
//   The mime type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Libium.Core
{
    using System.Text;

    // TODO Overoad == 
    // TODO override to string
    /// <summary>
    ///   The mime type.
    /// </summary>
    public class MimeType
    {
        #region Public Properties

        /// <summary>
        ///   Gets or sets the content type.
        /// </summary>
        public string ContentType { get; set; }

        /// <summary>
        ///   Gets or sets the file extensions.
        /// </summary>
        public string[] FileExtensions { get; set; }

        /// <summary>
        ///   Gets or sets the name.
        /// </summary>
        public string Name { get; set; }

        #endregion

        #region Public Methods and Operators

        /// <summary>
        ///   The to string.
        /// </summary>
        /// <returns> The <see cref="string" /> . </returns>
        public override string ToString()
        {
            var builder = new StringBuilder();
            builder.Append(this.Name);
            builder.Append(" (");

            var isNotFirst = false;
            foreach (var extension in this.FileExtensions)
            {
                if (isNotFirst)
                {
                    builder.Append(",");
                }

                builder.Append("*.");
                builder.Append(extension);
                isNotFirst = true;
            }

            builder.Append(")");

            return builder.ToString();
        }

        #endregion
    }
}